<template>
  <div class="home_two">
    <div class="titlea">
      <el-date-picker size="mini" v-model="startTime" style="margin: 0px 20px;" type="date" placeholder="开始时间"  value-format="yyyy-MM-dd"
        format="yyyy-MM-dd"></el-date-picker>
      <el-date-picker size="mini" v-model="endTime" style="margin: 0px 20px;" type="date" placeholder="结束时间"  value-format="yyyy-MM-dd"
        format="yyyy-MM-dd"></el-date-picker>
      <el-button @click="fetchData" size="mini" type="primary">查询</el-button>
      <!-- <span>前天</span>
      <span>昨天</span>
      <span>今天</span> -->
    </div>
    <el-table size="mini" @row-click="note" :data="tableData" border style="width: 100%">
      <el-table-column prop="day" label="日期" width="180"></el-table-column>
      <el-table-column prop="moduleName" label="彩种" width="180"></el-table-column>
      <el-table-column prop="issue" label="期数" width="180"></el-table-column>
      <el-table-column prop="quantity" label="笔数" width="180"></el-table-column>
      <el-table-column prop="itemAmount" label="金额" width="180"></el-table-column>
      <el-table-column prop="isWinName" label="中奖" width="180"></el-table-column>
      <el-table-column prop="winAmount" label="回水" width="180"></el-table-column>
      <el-table-column prop="profit" label="盈亏"></el-table-column>
    </el-table>
    <div>
      <!-- 分页 -->
      <el-pagination
      style="float:right;margin-top:20px"
        size="mini"
        class="pageNumage"
        @current-change="handleCurrentChange"
        background
        layout="prev, pager, next"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>

<script>
import { mapState } from "Vuex";
import moment from 'moment'
export default {
  name: "homeOne", 
  data() {
    return {
      tableData: [],
      startTime:moment(new Date()).format("YYYY-MM-DD"),
      endTime: moment(new Date()).format("YYYY-MM-DD"),
      pageNum: 1,
      total: 0,
      pritem: this.$route.query.titleid,
    };
  },
  created() {
    this.fetchData();
  },
  computed: {
    ...mapState(["typedt"]),
  },
  
  methods: {
    // buy(){
    //   this.fetchData();
    // },
    note(val){
      console.log(val,1661616166)
      this.$router.push({
        path: "note",
        query: {
          issue: val.issue
        }
      });
    },
   
    handleCurrentChange(val) {
      this.pageNum = val;
      this.fetchData();
    },
    // 历史接口
    fetchData() {
      this.$api.post(this.$url.order, {
         pageNum:this.pageNum,
         pageSize:10,
         startDay:this.startTime,
         endDay:this.endTime,
         module:this.typedt

      }, res => {
        if (res.data.code == 200) {
          console.log(res.data,"历史")
          this.tableData = res.data.data;
          this.total = res.data.count;
        } else {
          this.$message.error(res.data.msg);
        }
      });
    }
  }
};
</script>
<style lang="less" scoped>
// 历史账单
.home_two {
  width: 100%;
  .titlea {
    margin: 30px 10px;
    span {
      padding: 0px 10px;
    }
  }
}
</style>
